package com.jzo2o.foundations.controller.consumer;

import com.jzo2o.foundations.model.domain.ServeSearch;
import com.jzo2o.foundations.model.dto.response.ServeAggregationSimpleResDTO;
import com.jzo2o.foundations.model.dto.response.ServeAggregationTypeSimpleResDTO;
import com.jzo2o.foundations.model.dto.response.ServeCategoryResDTO;
import com.jzo2o.foundations.service.IESService;
import com.jzo2o.foundations.service.IRegionServeService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/customer/serve")
public class ConsumerServerController {
    @Autowired
    private IRegionServeService serveService;

    @Autowired
    private IESService esService;

    @GetMapping("/firstPageServeList")
    @ApiOperation("获取首页服务列表")
    public List<ServeCategoryResDTO> firstPageServeList(@RequestParam("regionId") Long regionId) {
        return serveService.firstPageServeList(regionId);
    }

    @GetMapping("/hotServeList")
    @ApiOperation("获取热门服务列表")
    public List<ServeAggregationSimpleResDTO> hotServeList(@RequestParam("regionId") Long regionId) {
        return serveService.hotServeList(regionId);
    }

    @GetMapping("/serveTypeList")
    @ApiOperation("获取区域服务类型列表")
    public List<ServeAggregationTypeSimpleResDTO> serveTypeList(@RequestParam("regionId") Long regionId) {
        return serveService.serveTypeList(regionId);
    }

    @GetMapping("/{id}")
    @ApiOperation("获取服务详情")
    public ServeAggregationSimpleResDTO serveDetail(@PathVariable("id") Long id) {
        return serveService.getServeDetailById(id);
    }

    @GetMapping("/search")
    @ApiOperation("服务搜索")
    public List<ServeSearch> search(@RequestParam(value = "cityCode") String cityCode,
                                    @RequestParam(value = "keyword", required = false) String keyword,
                                    @RequestParam(value = "serveTypeId", required = false) String serveTypeId) {
        return esService.search(cityCode, keyword, serveTypeId);
    }
}
